---
redirect_from:
  - /config/databases/pinot
---

# Pinot

Apache Pinot is a real-time distributed OLAP datastore purpose-built for low-latency, high-throughput analytics,
and perfect for user-facing analytical workloads.

## Prerequisites

- The hostname for the [Pinot][pinot] broker
- The port for the [Pinot][pinot] broker

## Setup

### Manual

Add the following to a `.env` file in your Cube project:

```dotenv
CUBEJS_DB_TYPE=pinot
CUBEJS_DB_HOST=http[s]://pinot.broker.host
CUBEJS_DB_PORT=8099
CUBEJS_DB_USER=pinot_user
CUBEJS_DB_PASS=**********
```

## Environment Variables

| Environment Variable | Description                                | Possible Values     | Required |
|----------------------|--------------------------------------------|---------------------|:--------:|
| `CUBEJS_DB_HOST`     | The host URL for your Pinot broker         | A valid host URL    |    ✅    |
| `CUBEJS_DB_PORT`     | The port for the database connection       | A valid port number |    ✅    |
| `CUBEJS_DB_USER`     | The username used to connect to the broker | A valid username    |    ❌    |
| `CUBEJS_DB_PASS`     | The password used to connect to the broker | A valid password    |    ❌    |

## Pre-Aggregation Feature Support

### count_distinct_approx

Measures of type
[`count_distinct_approx`][ref-schema-ref-types-formats-countdistinctapprox] can
be used in pre-aggregations when using Pinot as a source database. To learn more
about Pinot support for approximate aggregate functions, [click
here][pinot-docs-approx-agg-fns].

## Pre-aggregation build strategies

<InfoBox>

To learn more about pre-aggregation build strategies, [head
here][ref-caching-using-preaggs-build-strats].

</InfoBox>

| Feature       | Works with read-only mode? | Is default? |
|---------------|:--------------------------:|:-----------:|
| Simple        |             ✅             |      ✅     |
| Batching      |             -              |      -      |
| Export bucket |             -              |      -      |

By default, Pinot uses a simple strategy to build pre-aggregations.

### Simple

No extra configuration is required to configure simple pre-aggregation builds
for Pinot.

### Batching

Pinot does not support batching.

### Export bucket

Pinot does not support export buckets.

## SSL

Cube does not require any additional configuration to enable SSL as Pinot connections are made over HTTPS.

[pinot]: https://docs.pinot.apache.org/
[pinot-docs-approx-agg-fns]:
  https://docs.pinot.apache.org/users/user-guide-query/query-syntax/how-to-handle-unique-counting
[ref-recipe-enable-ssl]:
  /guides/recipes/data-sources/using-ssl-connections-to-data-source
[ref-schema-ref-types-formats-countdistinctapprox]: /reference/data-model/types-and-formats#count_distinct_approx
